#include <REGX52.H>
#include "Delay.h"
#include "LCD1602.h"
#include "I2C.h"
#include "KEY.h"

unsigned char num=0;
int main()
{
	unsigned char Key_num=0;
	LCD_Init();
	while(1)
	{
		Key_num=KeySelect();
        switch(Key_num)
		{
			case 1://数字加加
				num++;
				break;
			case 2://数字减减
				num--;
				break;
			case 3://存储数据
				Send_Message(1,num);
			Delay(5);//写周期5毫秒（要给芯片时间去存储），但读取不需要
			    LCD_ShowString(2,1,"Write OK");
				break;
			case 4://读取数据
				num=Receive_Message(1);
			    LCD_ShowString(2,1," Read OK");
				break;
		}
		LCD_ShowNum(1,1,num,5);
	}
	
	return 0;
}